package com.gongj.main;

import com.gongj.entity.User;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class RootBeanDefinitionTest {

	public static void main(String[] args) {
		//容器
		DefaultListableBeanFactory context = new DefaultListableBeanFactory();
		//属性的集合  在其父类 AbstractBeanDefinition 已经提到过了
		MutablePropertyValues mpvs = new MutablePropertyValues();
		mpvs.add("id",4L);
		mpvs.add("name","gongj");
		//BeanDefinition
		RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(User.class,null,mpvs);
		//注册到Spring容器中
		context.registerBeanDefinition("user",rootBeanDefinition);
		User user = (User)context.getBean("user");
		System.out.println(user);
	}
}
